<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         const cai={
            uname:'kun',
            age:2.5,
            fan:{
                uname:'ikun',
                age:99999,
                hobbit:['sing','dance']
            },
            hobbit:['sing','dance']
        }
        let feng={}
        function deepClone(newObj,oldObj){
            for(let key in oldObj){
                if(oldObj[key] instanceof Array){
                    newObj[key]=[]
                    
                    deepClone(newObj[key],oldObj[key])
                    //newObj[hobbit]  oldObj[hobbit]

                }else if(oldObj[key] instanceof Object){
                    newObj[key]={}
                    deepClone(newObj[key],oldObj[key])
                    //newObj[fan]  oldObj[fan]
                     // //newObj[hobbit]=oldObj[hobbit]

                   
                }else{
                    //newObj[hobbit][0]=oldObj[hobbit][0]
                     //newObj[uname]=oldObj[uname]
                    newObj[key]=oldObj[key]
                }
            }

        }
        deepClone(feng,cai)
        console.log(feng);

</script>
</body>
</html>